/*希望这里是一个 自由验证的包*/
import axios ,{AJAX_START,AJAX_SUCCESS,AJAX_ERROR} from  "../../../lib/networkAxios";
export  default {
    required (val,next) {
        return new Promise((resolve,reject) => {
            let empty= "^\\s{0}$";
            console.log(val)
            console.log("required:"+new RegExp(empty).test(val))
            if(new RegExp(empty).test(val)){
                return reject("失败")
            }else {
                return resolve("成功")
            }
        });
    },
    username (val,next) {
        return new Promise((resolve,reject) => {
                let username= "^[A-Za-z0-9_\\-\\u4e00-\\u9fa5]+$";
                console.log("username:"+new RegExp(username).test(val))
                if(new RegExp(username).test(val)){
                   return resolve("成功")
                }else {
                   return reject("失败")
                }
        });
    },
    mobile(val){
        return new Promise((resolve,reject) => {
            let mobile= "^0?(13|15|18|14|17)[0-9]{9}$";
            console.log("mobile:"+new RegExp(mobile).test(val))
            if(new RegExp(mobile).test(val)){
                return resolve("成功")
            }else {
                return reject("失败")
            }
        });
    },
    code(val){
        return new Promise((resolve,reject) => {
            let code= "^[0-9]{6}$";
            console.log("code:"+new RegExp(code).test(val))
            if(new RegExp(code).test(val)){
                return resolve("成功")
            }else {
                return reject("失败")
            }
        });
    },
    usernamepost(val){
        return axios.post(`${__SERVER_HOST__}/AdminApi/GetUserInfo`).catch(function (res) {
            return Promise.reject(res.data.data.msg)
        })
    }
}